Skip to content

GH#915: fix: emit wu_inline_login_error hook in pre-submit catch block#922

Merged
superdav42 merged 1 commit intomainfrom
feature/auto-20260424-023744-gh915
Apr 24, 2026
Merged

GH#915: fix: emit wu_inline_login_error hook in pre-submit catch block#922
superdav42 merged 1 commit intomainfrom
feature/auto-20260424-023744-gh915

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented Apr 24, 2026

What

Emit wu_inline_login_error action in the catch block that handles rejection of wu_before_inline_login_submitted promises.

Why

When Promise.all(hooks.applyFilters('wu_before_inline_login_submitted', [], field_type)) rejects (e.g. a captcha promise rejects), the catch block set this.login_error and returned false but never fired the wu_inline_login_error action. Addons that listen to that hook to reset captcha widgets or other UI state would silently no-op on this failure path, even though the AJAX error path already fires the hook correctly.

How

After setting this.login_error, call:

hooks.doAction('wu_inline_login_error', {
    data: {
        message: this.login_error,
    },
    originalError: err,
}, field_type);

This mirrors assets/js/checkout.js:1293 (the AJAX error handler) while wrapping the error in a structured object so addon callbacks receive consistent data regardless of which failure path fired.

Verification

  1. Register a wu_before_inline_login_submitted filter that returns a rejected promise.
  2. Trigger the inline login form.
  3. Confirm wu_inline_login_error fires and any registered callback (e.g. captcha reset) runs.
  4. Confirm wu_inline_login_error still fires on a normal AJAX login failure (regression check on the AJAX path).

Resolves #915


aidevops.sh v3.10.1 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 2m and 6,791 tokens on this as a headless worker.

Summary by CodeRabbit

  • New Features
    • Enhanced error handling for inline login failures with improved error reporting and diagnostics, providing better visibility and troubleshooting capabilities when login submission issues occur during checkout.

When Promise.all(hooks.applyFilters('wu_before_inline_login_submitted'))
rejects, the catch block set login_error but did not fire the
wu_inline_login_error action. Addons that reset captcha/widgets on
login failure (via that hook) would silently not run on this path.

Add hooks.doAction('wu_inline_login_error', ...) after setting
this.login_error, mirroring the same hook emission in the AJAX
error handler. The payload wraps the message and originalError so
addon callbacks receive consistent structure regardless of which
failure path fired.

Fixes #915
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

Adds a missing failure hook emission in the inline login flow when the wu_before_inline_login_submitted hook rejects. The wu_inline_login_error action is now triggered with normalized error payload containing the login error message and original error, enabling addons to respond to pre-submit promise rejections.

Changes

Cohort / File(s) Summary
Inline Login Error Handling
assets/js/checkout.js
Added emission of wu_inline_login_error hook in catch block for rejected wu_before_inline_login_submitted promises, with payload containing data.message and originalError to allow addons to reset captcha/widgets on this failure path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Feature/inline login hooks #913: Direct predecessor PR that introduced the inline login flow and prompted this fix via review feedback on the missing hook emission in the pre-submit rejection path.

Poem

🐰 A hop through the catch block, a promise denied,
Now the error hook springs with nowhere to hide!
Addons rejoice as wu_inline_login_error rings,
For captchas reset on rejection's swift wings! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: emitting the wu_inline_login_error hook in the pre-submit catch block, which directly aligns with the changeset.
Linked Issues check ✅ Passed The PR correctly implements the requirement from issue #915 by calling hooks.doAction('wu_inline_login_error', ...) in the catch block with the normalized payload (data.message and originalError), matching the proposed fix and resolving the quality-debt feedback.
Out of Scope Changes check ✅ Passed All changes are directly scoped to addressing the issue #915 requirement; the addition of the wu_inline_login_error hook emission in the catch block is the sole objective with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260424-023744-gh915

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@superdav42
Copy link
Copy Markdown
Collaborator Author

Merge Summary

Issue: #915 — quality-debt: emit wu_inline_login_error hook in pre-submit catch block

Change: Added hooks.doAction('wu_inline_login_error', ...) in the catch block at assets/js/checkout.js:1228-1234 that handles rejection of wu_before_inline_login_submitted promises. The AJAX error path already fired this hook (line 1293); the pre-submit catch path was missing it.

Files modified: assets/js/checkout.js (+19 lines)

Testing: JS syntax validated (node); logic mirrors the existing AJAX error handler pattern from PR #913.


aidevops.sh v3.10.1 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 2m on this as a headless worker. Overall, 13s since this issue was created.

@github-actions
Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
assets/js/checkout.js (1)

1244-1249: Optional: payload shape differs from the AJAX error path on Line 1312.

The new emission passes a normalized { data: { message }, originalError } object, but the AJAX failure path at Line 1312 still forwards the raw jqXHR error where message lives at error.responseJSON.data.message. Addon listeners therefore have to branch on payload shape to read the message. Consider normalizing the AJAX path to the same shape in a follow-up so both failure paths expose error.data.message uniformly (note: this would be a behavior change for existing listeners, so it's out of scope for this fix).

Also applies to: 1312-1312

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@assets/js/checkout.js` around lines 1244 - 1249, The 'wu_inline_login_error'
hook currently emits a normalized payload in the inline login path via
hooks.doAction(..., { data: { message: this.login_error }, originalError: err },
field_type) but the AJAX failure branch still forwards the raw jqXHR error
(error with message at error.responseJSON.data.message); update the AJAX error
handler that triggers hooks.doAction('wu_inline_login_error', ...) to construct
the same normalized shape (e.g., { data: { message: /* extract
responseJSON.data.message or fallback */ }, originalError: error }) so addon
listeners can read error.data.message consistently while preserving
originalError for debugging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@assets/js/checkout.js`:
- Around line 1244-1249: The 'wu_inline_login_error' hook currently emits a
normalized payload in the inline login path via hooks.doAction(..., { data: {
message: this.login_error }, originalError: err }, field_type) but the AJAX
failure branch still forwards the raw jqXHR error (error with message at
error.responseJSON.data.message); update the AJAX error handler that triggers
hooks.doAction('wu_inline_login_error', ...) to construct the same normalized
shape (e.g., { data: { message: /* extract responseJSON.data.message or fallback
*/ }, originalError: error }) so addon listeners can read error.data.message
consistently while preserving originalError for debugging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 98e34e82-25b7-4da2-8b55-cc2b859a981c

📥 Commits

Reviewing files that changed from the base of the PR and between 0b4cdca and d453261.

📒 Files selected for processing (1)
  • assets/js/checkout.js

@github-actions
Copy link
Copy Markdown

Performance Test Results

Performance test results for 2637b4f are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 41 37.78 MB 854.00 ms (-32.50 ms / -4% ) 167.50 ms (+4.50 ms / +3% ) 1039.50 ms (-59.50 ms / -6% ) 1942.00 ms (-72.00 ms / -4% ) 1860.80 ms (-65.40 ms / -4% ) 93.15 ms (+5.60 ms / +6% )
1 56 49.03 MB 917.00 ms (-20.00 ms / -2% ) 147.00 ms 1060.00 ms (-21.50 ms / -2% ) 2032.00 ms 1948.55 ms 82.55 ms

@superdav42 superdav42 merged commit a1c6361 into main Apr 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quality-debt: assets/js/checkout.js — PR #913 review feedback (medium)

1 participant